import random, math
class Team(object):
    def __init__(self, name="", task=None, idle=True, ability=50):
        "A software development team"
        self.name = name
        self.task = task
        self.idle = idle
        self.daysWorked = 0
        self.daysIdle = 0
        self.pay = 0
        self.ability = ability+(self.pay**2)/2
        self.exp = 0
        self.level = 1


    def getter(self,attribute):
        return eval('self.' + attribute)

    def setter(self,attribute,val):
        exec(('self.' + attribute + ' = ' + 'val'))
    
    def assignTask(self, task):
        self.task = task
        self.idle = False

    def adjustPay(self, p):
        self.pay = p
        self.ability = self.ability+(self.pay**2)/2
        
    def haveTask(self):
        return not self.idle

    def taskDone(self):
        if not self.task: return False
        else: return self.task.hard <= 0

    def tasknotDone(self):
        return not self.taskDone()

    def finishTask(self):
        self.task.done = True
        self.task = None
        self.idle = True

    def doWork(self):
        self.task.hard = self.task.hard - self.ability
        self.daysWorked+= 1
        self.task.days+= 1
        self.exp += 1

        expchart = [[1,3,10],[2,7,15],[3,12,25],[4,19,40],[5,28,60],[6,40,100]]

        for pair in expchart:
            if pair[0] == self.level and self.exp > pair[1]:
                self.level+= 1
                self.ability+= pair[2]
                break
        

    def noTask(self):
        return not self.haveTask()

    def goidle(self):
        self.daysIdle+= 1
        return True

    def __repr__(self):
        print "\n"
        print "Team: " + self.name
        print "----Ability: " + str(self.ability)
        if self.task:
            print "----Task: " + self.task.name
        else: print "----Task: No Task Assigned"
        print "----Idle?: " + str(self.idle)
        return ""

    def repr2(self):
        print "\n"
        print "[Team] " + self.name
        print "[Task Assigned] " + self.task.name
        print "\n"
        
